<script type="text/javascript">
    jQuery(document).ready(function(){
        // binds form submission and fields to the validation engine
        jQuery("#EmpleadoAjaxaddproductoForm").validationEngine();
    });
</script>
<script type="text/javascript">
    jQuery(document).ready(function() {
       
    var sheepItForm = jQuery('#sheepItForm').sheepIt({
        separator: '',
        allowRemoveLast: true,
        allowRemoveCurrent: true,
        allowRemoveAll: true,
        allowAdd: true,
        allowAddN: true,
        maxFormsCount: 20,
        minFormsCount: 0,
        iniFormsCount: 1
    });
});

</script>
<?php echo $this->Form->create(null, array('url' => array('controller' => 'trabajos', 'action' => 'ajaxaddproducto/'.$idtrab))); ?>
<table class="production">

<tr>
   <td colspan="2">MATERIALES DEL INVENTARIO</td>
   <td colspan="2">
<!-- sheepIt Form -->
<div id="sheepItForm">

<!-- Form template-->
   <div id="sheepItForm_template">
      <?php echo $this->Form->hidden(null, array('name'=>"data[Inventariostrabajo][#index#][hojasruta_id]", 'value'=>$hojarutaid));?>
      <label for="sheepItForm_#index#_phone">Producto <span id="sheepItForm_label"></span></label>
      <?php echo $this->Form->select(null, $inventarios, array('name'=>"data[Inventariostrabajo][#index#][inventario_id]", "class"=>"validate[required] input-text"));?>
      <label for="sheepItForm_#index#_machine">Ancho<span id="sheepItForm_label"></span></label>
      <?php echo $this->Form->text(null, array('name'=>"data[Inventariostrabajo][#index#][ancho]"));?>
      <label for="sheepItForm_#index#_machine">Litros <span id="sheepItForm_label"></span></label>
      <?php echo $this->Form->text(null, array('name'=>"data[Inventariostrabajo][#index#][litros]"));?>
      <a id="sheepItForm_remove_current">
	     <?php echo $this->Html->image('buttons/cross.png',array('class'=>'delete'))?>
      </a>
    </div>
<!-- /Form template-->

<!-- No forms template -->
    <div id="sheepItForm_noforms_template">Sin Inventario</div>
<!-- /No forms template-->
                   
<!-- Controls -->
<div id="sheepItForm_controls">
     <div id="sheepItForm_add" class="btn form add"><a><span>A&ntilde;adir</span></a></div>
     <div id="sheepItForm_remove_last" class="btn form remove"><a><span>Remover</span></a></div>
     <div id="sheepItForm_remove_all" class="btn form removeAll"><a><span>Remove todos</span></a></div>
</div>
<!-- /Controls -->
                   
</div>
<!-- /sheepIt Form -->
</td>
</tr>
<tr>
   <td>
    <?php echo $this->Form->end('Anadir');?>
   </td>
   <td>
   <a href="#" onclick="recargar()">Cerrar</a>
   </td>
</tr>
</table>
<script type="text/javascript">
    function recargar(){
        window.location.reload();
    }
</script>